package com.maxiaoke.boot.controller;

import com.maxiaoke.boot.bean.Account;
import com.maxiaoke.boot.bean.User;
import com.maxiaoke.boot.mapper.UserMapper;
import com.maxiaoke.boot.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class HelloController {

    // 引入Service
    @Autowired
    AccountService accountService;

    @ResponseBody // 测试，添加注解，让该方法返回json数据
    @GetMapping("/getacc")
    public Account getAccount(@RequestParam("id") Long accountid) {
        return accountService.getAccountByAccountId(accountid);
    }

    @Autowired
    UserMapper userMapper;

    @GetMapping("/testusermapper")
    public User testUserMapper(){
        User user = userMapper.selectById(1L);
        log.info("用户信息:{}",user);
        return null;
    }

    @Value("${person.name:李四}")
    private String name;

    /**
     * Profile环境测试
     */
    @GetMapping("/hello")
    public String hello(){
        return "Hello" + name;
    }

}
